package class10;

public class TestDemo {
    public static void main(String[] args) {
        String s = "hello";
        int i = scoreOfString(s);
        System.out.println("i = " + i);
    }

    public static int scoreOfString(String s) {
        char[] chars = s.toCharArray();
        char t = chars[0];
        int ans = 0;
        for (int i = 1; i < chars.length; i++) {
            ans += Math.abs(t - chars[i]);
            t = chars[i];
        }
        return ans;
    }
}
